//
//  Qb_SharedetailsViewController.m
//  Cd_Qb
//
//  Created by mac on 2018/3/14.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "Qb_SharedetailsViewController.h"
#import "Qb_TMoneyViewController.h"
#import "Qb_DetailsViewController.h"

#import "Qb_SharedetailsHeadView.h"
#import "Qb_SharedetailsTableViewCell.h"

@interface Qb_SharedetailsViewController ()<UITableViewDelegate,UITableViewDataSource,Qb_SharedetailsHeadDelegate>
@property (nonatomic,strong) Qb_SharedetailsHeadView*head;
@property (nonatomic,strong) UITableView *SharedtableView;
@end

@implementation Qb_SharedetailsViewController


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    self.title = @"分润明细";
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame= CGRectZero;
    [btn setTitle:@"提现明细" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(RightClick:) forControlEvents:UIControlEventTouchUpInside];
    btn.titleLabel.font = AdFont(14);
    UIBarButtonItem*RightBtn = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.rightBarButtonItem = RightBtn;
    
    [self.view addSubview:self.SharedtableView];
}



//点击提款
-(void)OnBtnClick{
    [self.navigationController pushViewController:Storyboard(@"Service",@"Qb_TMoneyViewController") animated:YES];
}

#pragma mark -- Action
//点击右边
-(void)RightClick:(UIButton *)sender{
    [self.navigationController pushViewController:[Qb_DetailsViewController new] animated:YES];
}


#pragma mark --UITableViewDelegate&&UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    Qb_SharedetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell loadData:@[]];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.navigationController pushViewController:Storyboard(@"Service", @"Qb_ShareCelldetailsViewController") animated:YES];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80*AdaptiveScale_W;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 44*AdaptiveScale_W;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 44*AdaptiveScale_W)];
    label.text = @"     利润明细";
    label.textAlignment = NSTextAlignmentLeft;
    label.font = AdFont(17);
    return label;
}



-(UITableView *)SharedtableView{
    if (!_SharedtableView) {
        _SharedtableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _SharedtableView.delegate = self;
        _SharedtableView.dataSource = self;
        _head = loadNibNamed(@"Qb_SharedetailsHeadView").lastObject;
        _head.delegate = self;
        CGRect frame = _head.frame;
        frame.size.height = frame.size.height*AdaptiveScale_W;
        _head.frame = frame;
        _SharedtableView.tableHeaderView = _head;
        _SharedtableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
        _SharedtableView.showsVerticalScrollIndicator = NO;
        _SharedtableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_SharedtableView registerNib:[UINib nibWithNibName:@"Qb_SharedetailsTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
//        WS(weakself);
//        _JointableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
//            [weakself loadNewData];
//        } ];
//
//        _JointableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//            //刷新时候，需要执行的代码。一般是请求更多数据，请求成功之后，刷新列表
//            [weakself loadMoreData];
//        }];
    }
    return _SharedtableView;
}

@end
